﻿using Furion.DatabaseAccessor;
using LimaLims.Core.Entity.System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System.ComponentModel.DataAnnotations;

namespace LimaLims.Core.Entity.Basic
{
    /// <summary>
    /// 检验方案
    /// </summary>
    [Comment("检验方案")]
    public class InspectionScheme : DEntityTenant, IEntityTypeBuilder<InspectionScheme>
    {
        /// <summary>
        /// 编号
        /// </summary>
        [Comment("编号")]
        public string Code { get; set; }

        /// <summary>
        /// 名称
        /// </summary>
        [Comment("名称")]
        public string Name { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        [Comment("备注"), MaxLength(100)]
        public string Remark { get; set; }

        /// <summary>
        /// 检验方案项目集合
        /// </summary>
        public ICollection<InspectionData> InspectionDatas { get; set; }


        public void Configure(EntityTypeBuilder<InspectionScheme> entityBuilder, DbContext dbContext, Type dbContextLocator)
        {
            entityBuilder.HasMany(x => x.InspectionDatas)
                 .WithOne(x => x.InspectionScheme)
                 .HasForeignKey(x => x.InspectionSchemeId);
        }
    }
}
